package com.xthh._function.MyPopWindow3;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xt.xthh.R;
import com.xthh._function.HH_Logging;
import com.xthh._function.HH_SystemUtil;

import java.util.List;

/**
 * Copyright: Copyright (c) 2017-2025
 * Company:
 *
 * @author: 赵小贱
 * @date: 2017/8/23
 * describe:
 */
public class HH_SpinerAdapter3 extends BaseAdapter {



    public static interface IOnItemSelectListener {
        public void onItemClick(int pos);
    }

    private List<HH_T_SpinnerRosInfo> mObjects;
    private LayoutInflater mInflater;
    private int select = 0;
    Context ctx;

    public HH_SpinerAdapter3(Context context, List<HH_T_SpinnerRosInfo> mObjects, int sel) {
        this.mObjects = mObjects;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        select = sel;
        ctx = context;
    }





    @Override
    public int getCount() {

        return mObjects.size();
    }

    @Override
    public Object getItem(int pos) {
        return mObjects.get(pos).toString();
    }

    @Override
    public long getItemId(int pos) {
        return pos;
    }

    @Override
    public View getView(int pos, View convertView, ViewGroup arg2) {
        ViewHolder viewHolder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.spiner_item_layout3, null);
            viewHolder = new ViewHolder();
            viewHolder.imageView_dither = convertView.findViewById(R.id.imageView_dither);
            viewHolder.textView_name =  convertView.findViewById(R.id.textView_name);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.textView_name.setText(mObjects.get(pos).getName());

        HH_Logging.i("HH_SpinerAdapter3", "select %d,%d,%b", select, pos, mObjects.get(pos).isSelect());

        if (mObjects.get(pos).isSelect()){
            HH_SystemUtil.setTextBold(viewHolder.textView_name, true);
            viewHolder.imageView_dither.setBackground(mObjects.get(pos).getIcon_down());
        } else {
            HH_SystemUtil.setTextBold(viewHolder.textView_name, false);
            viewHolder.imageView_dither.setBackground(mObjects.get(pos).getIcon_up());
        }

        return convertView;
    }


    public static class ViewHolder {
        public ImageView imageView_dither;
        public TextView textView_name;
    }

}